<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<button>发送1</button>
<button>发送2</button>
</body>
<script>
	document.querySelectorAll("button")[0].onclick = function () {
		const xhr = new XMLHttpRequest();
		xhr.open("get", "http://127.0.0.1/sum?a=10&b=20");
		xhr.send();
		xhr.onload = function () {
			console.log(xhr.response);
		}
	}
    document.querySelectorAll("button")[1].onclick = function () {
      const xhr = new XMLHttpRequest();
      xhr.open("post", "http://127.0.0.1/sum");
      xhr.setRequestHeader("Content-Type","application/json")
      xhr.send(JSON.stringify({
        a:200,
        b:400
      }));
      xhr.onload = function () {
        console.log(xhr.response);
      }
    }
</script>
</html>